/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙，邂逅框架梦]
 * 
 * https://zhiqim.org/project/zhiqim_framework/zhiqim_kernel.htm
 *
 * Zhiqim Kernel is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package org.zhiqim.kernel.model.results;

/**
 * 无值整型错误对象，用于替换boolean型返回错误码
 *
 * @version v1.0.0 @author zgzou 2021年11月23日 新建与整理
 */
public class R3
{
    private static final R3 C = new R3();
    private int error;
    
    /** 是否成功 */
    public boolean success()
    {
        return error == 0;
    }
    
    /** 是否失败 */
    public boolean failure()
    {
        return !success();
    }

    /************************************************************************/
    //静态方法创建对象
    /************************************************************************/
    
    /** 静态方法创建对象并初始化正确值 */
    public static R3 correct()
    {
        return C;
    }
    
    /** 静态方法创建对象并初始化错误码 */
    public static R3 error(int error)
    {
        R3 r = new R3();
        r.error = error;
        return r;
    }
    
    /************************************************************************/
    //获取值
    /************************************************************************/
    
    public int error()
    {
        return error;
    }
}
